import Vue from 'vue'
import Components from '@/components'
import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css
import CheckPermission from './mixin/checkPermission'
import App from './App'
import store from './store'
import router from './router'
import i18n from '@/lang'
import * as directives from '@/directives'// 引入全部自定义指令
import * as filters from '@/filters'
import '@/icons' // icon
import '@/permission' // permission control

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要多语言版 element-ui，按如下方式声明
Vue.use(ElementUI, { i18n: (key) => i18n.t(key) })
Object.keys(directives).forEach(key => { // 转换为数组并循环
  Vue.directive(key, directives[key])// 注册全部自定义指令
})
Object.keys(filters).forEach(key => { // 转换为数组并循环
  Vue.filter(key, filters[key])// 注册全部自定义过滤器
})
Vue.config.productionTip = false
Vue.use(Components)// 注册全局自定义组件
Vue.mixin(CheckPermission)// 全局混入权限检查
new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
